function WorkerPhotographer() {
};

WorkerPhotographer.instance = function(callbackFunc) {
  var popupBox = new PopupBox(), _self = this;
  var popupBox2 = new PopupBox2();
  var model = Model.instance('{{$smarty.const.MODEL_NAME_USER_PHOTOGRAPHER|escape:javascript}}', '{{$smarty.const.MODEL_TITLE_USER_PHOTOGRAPHER|escape:javascript}}', '{{$smarty.const.MODEL_TYPE_PRODUCT|escape:javascript}}');
  
  //Create model here...
  var state1 = State.instance(model, 0, 'not activate (No Wedding Day)');
  var state2 = State.instance(model, 1, 'arrange  photographer');
  var state3 = State.instance(model, 2, 'confirm photographer ');
  var state4 = State.instance(model, 3, 'remind photographer ');
  var state5 = State.instance(model, 4, 'receive photo DVD');
  var state6 = State.instance(model, 5, 'backup photo DVD');
  var state7 = State.instance(model, 6, 'CUS pick up photo DVD');
  var state8 = State.instance(model, 7, 'CUS picked up photo DVD');
  var transition1 = Transition.instance('select', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.dop, -60);
  var transition2 = Transition.instance('confirmed', state3, state4, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.dop, -3);
  var transition3 = Transition.instance('reminded', state4, state5, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.dop, 5);
  var transition4 = Transition.instance('received', state5, state6, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.normal, 2);
  var transition5 = Transition.instance('completed', state6, state7, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.normal, 14);
  var transition6 = Transition.instance('picked up', state7, state8, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.none);
  var transition7 = Transition.instance('rmd CUS', state7, state7, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.mixed, 14);
  
  var transition8 = Transition.instance('completed', state6, state7, '{{$smarty.const.USER_TYPE_CUSTOMER_SERVICE|escape:javascript}}', DlmanageUtils.normal, 3);
  
  var transition9 = Transition.instance('select', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.dop, -60);
  var transition10 = Transition.instance('confirmed', state3, state4, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.dop, -3);
  var transition11 = Transition.instance('reminded', state4, state5, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.dop, 5);
  var transition12 = Transition.instance('received', state5, state6, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 2);
  var transition13 = Transition.instance('completed', state6, state7, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.normal, 14);
  var transition14 = Transition.instance('picked up', state7, state8, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.none);
  var transition15 = Transition.instance('rmd CUS', state7, state7, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.mixed, 14);
  
  var transition16 = Transition.instance('select', state2, state3, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.dop, -60);
  var transition17 = Transition.instance('confirmed', state3, state4, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.dop, -3);
  var transition18 = Transition.instance('reminded', state4, state5, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.dop, 5);
  var transition19 = Transition.instance('received', state5, state6, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 2);
  var transition20 = Transition.instance('completed', state6, state7, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.normal, 14);
  var transition21 = Transition.instance('picked up', state7, state8, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.none);
  var transition22 = Transition.instance('rmd CUS', state7, state7, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.mixed, 14);
  
  transition4.validate = function(produce, user, date, options) { if (transition4.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.date)) { return false; } else { return true; } };
  transition7.validate = function(produce, user, date, options) { if (transition7.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  
  transition12.validate = function(produce, user, date, options) { if (transition12.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.date)) { return false; } else { return true; } };
  transition15.validate = function(produce, user, date, options) { if (transition15.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };
  
  transition19.validate = function(produce, user, date, options) { if (transition19.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.date)) { return false; } else { return true; } };
  transition22.validate = function(produce, user, date, options) { if (transition22.position != user.type) { return false; } if (SimpleDate.toStamp(date) < SimpleDate.toStamp(produce.deadline)) { return false; } else { return true; } };

  
  transition1.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             if (produce.user_account == '') {
                                                                                                               window.alert('选择一个工作人员');
                                                                                                               return;
                                                                                                             }
                                                                                                             options.extra = produce.user_account;
                                                                                                             
                                                                                                            
                                                                                                             
                                                                                                             var func3 = function(){
                                                                                                                DlmanageUtils.operate(transition1, pos, callbackFunc, produce, user, date, options);
                                                                                                             }
                                                                                                             
                                                                                                              DlmanageUtils.sendEmail(produce,pos,func3,callbackFunc,user);
                                                                                                             popupBox._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox, pos, div, func1, func2);
                                                                                    new DialogAssignee(div, produce, { php: 'customphp/mysqlread.php', condition: 'd.pEnabled = 1 and d.isdisplay = 0', orderTrackId: produce.orderTrackId, photo: true});
                                                                                  };


  transition2.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  options.func = function(div, pos, options) { MiscUtils.dialog(popupBox, pos, div); };
                                                                                  
                                                                                  
                                                                                                           options.extra = produce.user_account;
                                                                                                           
                                                                                                               var func3 = function(){
                                                                                                                DlmanageUtils.operate(transition2, pos, callbackFunc, produce, user, date, options);
                                                                                                             }
                                                                                                             
                                                                                                              DlmanageUtils.sendEmail(produce,pos,func3,callbackFunc,user);
                                                                                
                                                                                };   

  transition3.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    options.stage = 2;
                                                                                    options.func = function(div, customer, options) { new DialogLocation(div, customer, options); };
                                                                                    
                                                                                    var func3 = function(){
                                                                                      DlmanageUtils.operate3(transition3, pos, callbackFunc, produce, user, date, options);
                                                                                    }
                                                                                    
                                                                                     DlmanageUtils.sendEmail(produce,pos,func3,callbackFunc,user);
                                                                                  };
                                                                                  
  transition4.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._text == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._text;
                                                                                                             DlmanageUtils.operate(transition4, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, {t: '请写下Photo DVD的数量', func: function() { callbackFunc(); } });
                                                                                    new DialogInput(div, produce, { title: '' });
                                                                                  };
                                                                                  
  
  transition6.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    options.stage = 3;
                                                                                    options.orderDate = produce.date;
                                                                                    options.user = user;
                                                                                    options.date = date;
                                                                                    options.orderFlag = produce.orderFlag;
                                                                                    options.orderTrackId = produce.orderTrackId;
                                                                                    options.orderId = produce.orderId;
                                                                                    options.customerId = produce.customerId;
                                                                                    DlmanageUtils.operate2(transition6, pos, callbackFunc, produce, user, date, options);
                                                                                  };
  
  transition9.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  var div = document.createElement('div');
                                                                                  var func1 = function() { if (!options) {
                                                                                                             options = {};
                                                                                                           }
                                                                                                           if (produce.user_account == '') {
                                                                                                             window.alert('选择一个工作人员');
                                                                                                             return;
                                                                                                           }
                                                                                                           options.extra = produce.user_account;
                                                                                                             var func3 = function(){
                                                                                                                DlmanageUtils.operate(transition9, pos, callbackFunc, produce, user, date, options);
                                                                                                             }
                                                                                                             
                                                                                                              DlmanageUtils.sendEmail(produce,pos,func3,callbackFunc,user);
                                                                                                           popupBox._close();
                                                                                                         };
                                                                                  var func2 = function() { popupBox._close();
                                                                                                           callbackFunc();
                                                                                                         };
                                                                                  MiscUtils.dialog(popupBox, pos, div, func1, func2);
                                                                                  new DialogAssignee(div, produce, { php: 'customphp/mysqlread.php', condition: 'd.pEnabled = 1 and d.isdisplay = 0', orderTrackId: produce.orderTrackId, photo: true});
                                                                                };

  transition10.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  options.func = function(div, pos, options) { MiscUtils.dialog(popupBox, pos, div); };
                                                                                  
                                                                                  
                                                                                                           options.extra = produce.user_account;
                                                                                                           
                                                                                                               var func3 = function(){
                                                                                                                DlmanageUtils.operate(transition10, pos, callbackFunc, produce, user, date, options);
                                                                                                             }
                                                                                                             
                                                                                                              DlmanageUtils.sendEmail(produce,pos,func3,callbackFunc,user);
                                                                                
                                                                                };   


  transition11.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    options.stage = 2;
                                                                                    options.func = function(div, customer, options) { new DialogLocation(div, customer, options); };
                                                                                    
                                                                                    var func3 = function(){
                                                                                     DlmanageUtils.operate3(transition11, pos, callbackFunc, produce, user, date, options);
                                                                                    }
                                                                                     DlmanageUtils.sendEmail(produce,pos,func3,callbackFunc,user);
                                                                                  };
                                                                                
  transition12.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._text == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._text;
                                                                                                             DlmanageUtils.operate(transition12, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, {t: '请写下Photo DVD的数量', func: function() { callbackFunc(); } });
                                                                                    new DialogInput(div, produce, { title: '' });
                                                                                  };
                                                                                

  transition14.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    options.stage = 3;
                                                                                    options.orderDate = produce.date;
                                                                                    options.user = user;
                                                                                    options.date = date;
                                                                                    options.orderFlag = produce.orderFlag;
                                                                                    options.orderTrackId = produce.orderTrackId;
                                                                                    options.orderId = produce.orderId;
                                                                                    options.customerId = produce.customerId;
                                                                                    DlmanageUtils.operate2(transition14, pos, callbackFunc, produce, user, date, options);
                                                                                  };
 transition16.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  options.func = function(div, pos, options) { MiscUtils.dialog(popupBox, pos, div); };
                                                                                  
                                                                                  var div = document.createElement('div');
                                                                                  
                                                                                  var func1 = function() { if (!options) {
                                                                                                             options = {};
                                                                                                           }
                                                                                                           if (produce.user_account == '') {
                                                                                                             window.alert('选择一个工作人员');
                                                                                                             return;
                                                                                                           }
                                                                                                           options.extra = produce.user_account;
                                                                                                           
                                                                                                             var func3 = function(){
                                                                                                                DlmanageUtils.operate(transition16, pos, callbackFunc, produce, user, date, options);
                                                                                                             }
                                                                                                             
                                                                                                              DlmanageUtils.sendEmail(produce,pos,func3,callbackFunc,user);
                                                                                                           popupBox._close();
                                                                                                         };
                                                                                  var func2 = function() { 
                                                                                                           popupBox._close();
                                                                                                           callbackFunc();
                                                                                                         };
                                                                                  MiscUtils.dialog(popupBox, pos, div, func1, func2);
                                                                                  new DialogAssignee(div, produce, { php: 'customphp/mysqlread.php', condition: 'd.pEnabled = 1 and d.isdisplay = 0', orderTrackId: produce.orderTrackId, photo: true});
                                                                               
                                                                               

                                                                                
                                                                                
                                                                                }; 
                                                                                
                                                                                
  transition17.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  options.func = function(div, pos, options) { MiscUtils.dialog(popupBox, pos, div); };
                                                                                  
                                                                                  
                                                                                                           options.extra = produce.user_account;
                                                                                                           
                                                                                                               var func3 = function(){
                                                                                                                DlmanageUtils.operate(transition17, pos, callbackFunc, produce, user, date, options);
                                                                                                             }
                                                                                                             
                                                                                                              DlmanageUtils.sendEmail(produce,pos,func3,callbackFunc,user);
                                                                                
                                                                                };                                                                                 
                                                                                
  transition18.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    options.stage = 2;
                                                                                    options.func = function(div, customer, options) { new DialogLocation(div, customer, options); };
                                                                                    
                                                                                    var func3 = function(){
                                                                                      DlmanageUtils.operate3(transition18, pos, callbackFunc, produce, user, date, options);
                                                                                    }
                                                                                     DlmanageUtils.sendEmail(produce,pos,func3,callbackFunc,user);
                                                                                  };
                                                                                
  transition19.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._text == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._text;
                                                                                                             DlmanageUtils.operate(transition19, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, {t: '请写下Photo DVD的数量', func: function() { callbackFunc(); } });
                                                                                    new DialogInput(div, produce, { title: '' });
                                                                                  };
                                                                                

  transition21.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    options.stage = 3;
                                                                                    options.orderDate = produce.date;
                                                                                    options.user = user;
                                                                                    options.date = date;
                                                                                    options.orderFlag = produce.orderFlag;
                                                                                    options.orderTrackId = produce.orderTrackId;
                                                                                    options.orderId = produce.orderId;
                                                                                    options.customerId = produce.customerId;
                                                                                    DlmanageUtils.operate2(transition21, pos, callbackFunc, produce, user, date, options);
                                                                                  };
  model.states = [ state1, state2, state3, state4, state5, state6, state7, state8 ];
  model.transitions = [ transition1, transition2, transition3, transition4, transition5, transition6, transition7, transition8, transition9, transition10, transition11, transition12, transition13, transition14, transition15, transition16, transition17, transition18, transition19, transition20,
                        transition21, transition22 ];
  return model;
};